home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_perl.idb / usr / freeware / catman / p_man / cat3 / CGI::Push.Z / CGI::Push
Encoding:
Text File  |  1998-10-28  |  10.4 KB  |  331 lines

  1.  
  2.  
  3.  
  4.      CCCCGGGGIIII::::::::PPPPuuuusssshhhh((((3333))))    22223333////JJJJuuuullll////99998888 ((((ppppeeeerrrrllll 5555....000000005555,,,, ppppaaaattttcccchhhh 00002222))))      CCCCGGGGIIII::::::::PPPPuuuusssshhhh((((3333))))
  5.  
  6.  
  7.  
  8.      NNNNAAAAMMMMEEEE
  9.       CGI::Push - Simple Interface to Server Push
  10.  
  11.      SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
  12.           use CGI::Push qw(:standard);
  13.  
  14.           do_push(-next_page=>\&next_page,
  15.               -last_page=>\&last_page,
  16.               -delay=>0.5);
  17.  
  18.           sub next_page {
  19.           my($q,$counter) = @_;
  20.           return undef if $counter >= 10;
  21.           return start_html('Test'),
  22.              h1('Visible'),"\n",
  23.              "This page has    been called ", strong($counter)," times",
  24.              end_html();
  25.         }
  26.  
  27.            sub last_page {
  28.            my($q,$counter) = @_;
  29.            return start_html('Done'),
  30.               h1('Finished'),
  31.               strong($counter),' iterations.',
  32.               end_html;
  33.            }
  34.  
  35.  
  36.      DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
  37.       CGI::Push is a subclass of the CGI object created by CGI.pm.
  38.       It is    specialized for    server push operations,    which allow
  39.       you to create    animated pages whose content changes at
  40.       regular intervals.
  41.  
  42.       You provide CGI::Push    with a pointer to a subroutine that
  43.       will draw one    page.  Every time your subroutine is called,
  44.       it generates a new page.  The    contents of the    page will be
  45.       transmitted to the browser in    such a way that    it will
  46.       replace what was there beforehand.  The technique will work
  47.       with HTML pages as well as with graphics files, allowing you
  48.       to create animated GIFs.
  49.  
  50.      UUUUSSSSIIIINNNNGGGG CCCCGGGGIIII::::::::PPPPuuuusssshhhh
  51.       CGI::Push adds one new method    to the standard    CGI suite,
  52.       _d_o__p_u_s_h().  When you call this method, you pass it a
  53.       reference to a subroutine that is responsible    for drawing
  54.       each new page, an interval delay, and    an optional subroutine
  55.       for drawing the last page.  Other optional parameters
  56.       include most of those    recognized by the CGI _h_e_a_d_e_r() method.
  57.  
  58.       You may call _d_o__p_u_s_h() in the    object oriented    manner or not,
  59.       as you prefer:
  60.  
  61.  
  62.  
  63.      Page 1                        (printed 10/23/98)
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.      CCCCGGGGIIII::::::::PPPPuuuusssshhhh((((3333))))    22223333////JJJJuuuullll////99998888 ((((ppppeeeerrrrllll 5555....000000005555,,,, ppppaaaattttcccchhhh 00002222))))      CCCCGGGGIIII::::::::PPPPuuuusssshhhh((((3333))))
  71.  
  72.  
  73.  
  74.           use CGI::Push;
  75.           $q = new CGI::Push;
  76.           $q->do_push(-next_page=>\&draw_a_page);
  77.  
  78.           -or-
  79.  
  80.           use CGI::Push qw(:standard);
  81.           do_push(-next_page=>\&draw_a_page);
  82.  
  83.       Parameters are as follows:
  84.  
  85.       -next_page
  86.  
  87.           do_push(-next_page=>\&my_draw_routine);
  88.  
  89.           This required parameter points to    a reference to a
  90.           subroutine responsible for drawing each new page.     The
  91.           subroutine should    expect two parameters consisting of
  92.           the CGI object and a counter indicating the number of
  93.           times the    subroutine has been called.  It    should return
  94.           the contents of the page as an aaaarrrrrrrraaaayyyy of one or more
  95.           items to print. It can return a false value (or an empty
  96.           array) in    order to abort the redrawing loop and print
  97.           out the final page (if any)
  98.  
  99.           sub my_draw_routine {
  100.               my($q,$counter) =    @_;
  101.               return undef if $counter > 100;
  102.               return start_html('testing'),
  103.                  h1('testing'),
  104.                  "This page    called $counter    times";
  105.           }
  106.  
  107.           You are of course    free to    refer to create    and use    global
  108.           variables    within your draw routine in order to achieve
  109.           special effects.
  110.  
  111.       -last_page
  112.           This optional parameter points to    a reference to the
  113.           subroutine responsible for drawing the last page of the
  114.           series.  It is called after the -next_page routine
  115.           returns a    false value.  The subroutine itself should
  116.           have exactly the same calling conventions    as the
  117.           -next_page routine.
  118.  
  119.       -type
  120.           This optional parameter indicates    the content type of
  121.           each page.  It defaults to "text/html".  Normally    the
  122.           module assumes that each page is of a homogenous MIME
  123.           type.  However if    you provide either of the magic    values
  124.           "heterogeneous" or "dynamic" (the    latter provided    for
  125.           the convenience of those who hate    long parameter names),
  126.  
  127.  
  128.  
  129.      Page 2                        (printed 10/23/98)
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.      CCCCGGGGIIII::::::::PPPPuuuusssshhhh((((3333))))    22223333////JJJJuuuullll////99998888 ((((ppppeeeerrrrllll 5555....000000005555,,,, ppppaaaattttcccchhhh 00002222))))      CCCCGGGGIIII::::::::PPPPuuuusssshhhh((((3333))))
  137.  
  138.  
  139.  
  140.           you can specify the MIME type -- and other header    fields
  141.           -- on a per-page basis.  See "heterogeneous pages" for
  142.           more details.
  143.  
  144.       -delay
  145.           This indicates the delay,    in seconds, between frames.
  146.           Smaller delays refresh the page faster.  Fractional
  147.           values are allowed.
  148.  
  149.           IIIIffff nnnnooootttt ssssppppeeeecccciiiiffffiiiieeeedddd,,,,    ----ddddeeeellllaaaayyyy wwwwiiiillllllll ddddeeeeffffaaaauuuulllltttt ttttoooo 1111 sssseeeeccccoooonnnndddd
  150.  
  151.       -cookie, -target, -expires
  152.           These have the same meaning as the like-named parameters
  153.           in _C_G_I::_h_e_a_d_e_r().
  154.  
  155.       HHHHeeeetttteeeerrrrooooggggeeeennnneeeeoooouuuussss    PPPPaaaaggggeeeessss
  156.  
  157.       Ordinarily all pages displayed by CGI::Push share a common
  158.       MIME type.  However by providing a value of "heterogeneous"
  159.       or "dynamic" in the _d_o__p_u_s_h()    -type parameter, you can
  160.       specify the MIME type    of each    page on    a case-by-case basis.
  161.  
  162.       If you use this option, you will be responsible for
  163.       producing the    HTTP header for    each page.  Simply modify your
  164.       draw routine to look like this:
  165.  
  166.           sub my_draw_routine {
  167.           my($q,$counter) = @_;
  168.           return header('text/html'),    # note we're producing the header here
  169.              start_html('testing'),
  170.              h1('testing'),
  171.              "This page called $counter times";
  172.           }
  173.  
  174.       You can add any header fields    that you like, but some
  175.       (cookies and status fields included) may not be interpreted
  176.       by the browser.  One interesting effect is to    display    a
  177.       series of pages, then, after the last    page, to redirect the
  178.       browser to a new URL.     Because _r_e_d_i_r_e_c_t() does b<not>    work,
  179.       the easiest way is with a -refresh header field, as shown
  180.       below:
  181.  
  182.  
  183.  
  184.  
  185.  
  186.  
  187.  
  188.  
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195.      Page 3                        (printed 10/23/98)
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202.      CCCCGGGGIIII::::::::PPPPuuuusssshhhh((((3333))))    22223333////JJJJuuuullll////99998888 ((((ppppeeeerrrrllll 5555....000000005555,,,, ppppaaaattttcccchhhh 00002222))))      CCCCGGGGIIII::::::::PPPPuuuusssshhhh((((3333))))
  203.  
  204.  
  205.  
  206.           sub my_draw_routine {
  207.           my($q,$counter) = @_;
  208.           return undef if $counter > 10;
  209.           return header('text/html'),    # note we're producing the header here
  210.              start_html('testing'),
  211.              h1('testing'),
  212.              "This page called $counter times";
  213.           }
  214.  
  215.           sub my_last_page {
  216.           header(-refresh=>'5; URL=http://somewhere.else/finished.html',
  217.              -type=>'text/html'),
  218.           start_html('Moved'),
  219.           h1('This is the last page'),
  220.           'Goodbye!'
  221.            hr,
  222.            end_html;
  223.           }
  224.  
  225.  
  226.       CCCChhhhaaaannnnggggiiiinnnngggg tttthhhheeee PPPPaaaaggggeeee DDDDeeeellllaaaayyyy oooonnnn tttthhhheeee FFFFllllyyyy
  227.  
  228.       If you would like to control the delay between pages on a
  229.       page-by-page basis, call _p_u_s_h__d_e_l_a_y()    from within your draw
  230.       routine.  _p_u_s_h__d_e_l_a_y() takes a single    numeric    argument
  231.       representing the number of seconds you wish to delay after
  232.       the current page is displayed    and before displaying the next
  233.       one.    The delay may be fractional.  Without parameters,
  234.       _p_u_s_h__d_e_l_a_y() just returns the    current    delay.
  235.  
  236.      IIIINNNNSSSSTTTTAAAALLLLLLLLIIIINNNNGGGG    CCCCGGGGIIII::::::::PPPPuuuusssshhhh SSSSCCCCRRRRIIIIPPPPTTTTSSSS
  237.       Server push scripts mmmmuuuusssstttt be installed    as no-parsed-header
  238.       (NPH)    scripts    in order to work correctly.  On    Unix systems,
  239.       this is most often accomplished by prefixing the script's
  240.       name with "nph-". Recognition    of NPH scripts happens
  241.       automatically    with WebSTAR and Microsoft IIS.     Users of
  242.       other    servers    should see their documentation for help.
  243.  
  244.      CCCCAAAAVVVVEEEEAAAATTTTSSSS
  245.       This is a new    module.     It hasn't been    extensively tested.
  246.  
  247.      AAAAUUUUTTTTHHHHOOOORRRR IIIINNNNFFFFOOOORRRRMMMMAAAATTTTIIIIOOOONNNN
  248.       be used and modified freely, but I do    request    that this
  249.       copyright notice remain attached to the file.     You may
  250.       modify this module as    you wish, but if you redistribute a
  251.       modified version, please attach a note listing the
  252.       modifications    you have made.
  253.  
  254.       Address bug reports and comments to:
  255.       lstein@genome.wi.mit.edu
  256.  
  257.      BBBBUUUUGGGGSSSS
  258.  
  259.  
  260.  
  261.      PPPPaaaaggggeeee 4444                        ((((pppprrrriiiinnnntttteeeedddd 11110000////22223333////99998888))))
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268.      CCCCGGGGIIII::::::::PPPPuuuusssshhhh((((3333))))    22223333////JJJJuuuullll////99998888 ((((ppppeeeerrrrllll 5555....000000005555,,,, ppppaaaattttcccchhhh 00002222))))      CCCCGGGGIIII::::::::PPPPuuuusssshhhh((((3333))))
  269.  
  270.  
  271.  
  272.       This section intentionally left blank.
  273.  
  274.      SSSSEEEEEEEE AAAALLLLSSSSOOOO
  275.       the _C_G_I::_C_a_r_p    manpage, the _C_G_I manpage
  276.  
  277.  
  278.  
  279.  
  280.  
  281.  
  282.  
  283.  
  284.  
  285.  
  286.  
  287.  
  288.  
  289.  
  290.  
  291.  
  292.  
  293.  
  294.  
  295.  
  296.  
  297.  
  298.  
  299.  
  300.  
  301.  
  302.  
  303.  
  304.  
  305.  
  306.  
  307.  
  308.  
  309.  
  310.  
  311.  
  312.  
  313.  
  314.  
  315.  
  316.  
  317.  
  318.  
  319.  
  320.  
  321.  
  322.  
  323.  
  324.  
  325.  
  326.  
  327.      Page 5                        (printed 10/23/98)
  328.  
  329.  
  330.  
  331.